#!/bin/bash

# 开发工具演示脚本
# 展示如何使用 uv 调用各种开发工具

echo "=== 开发工具演示 ==="
echo

echo "1. 检查当前代码格式（不修改）"
echo "命令: uv run black --check --diff src/ tests/"
uv run black --check --diff src/ tests/
echo

echo "2. 运行 Ruff 代码检查"
echo "命令: uv run ruff check src/ tests/"
uv run ruff check src/ tests/
echo

echo "3. 运行 MyPy 类型检查"
echo "命令: uv run mypy src/"
uv run mypy src/
echo

echo "4. 对比：检查修复后的文件"
echo "命令: uv run mypy src/demo/calculator_fixed.py src/demo/utils_fixed.py"
uv run mypy src/demo/calculator_fixed.py src/demo/utils_fixed.py
echo

echo "5. 格式化代码"
echo "命令: uv run black src/ tests/"
uv run black src/ tests/
echo

echo "6. 自动修复 Ruff 发现的问题"
echo "命令: uv run ruff check --fix src/ tests/"
uv run ruff check --fix src/ tests/
echo

echo "7. 运行测试（如果存在）"
echo "命令: uv run pytest tests/ -v"
if [ -f "tests/test_calculator.py" ]; then
    uv run pytest tests/ -v
else
    echo "测试文件不存在或有导入问题"
fi
echo

echo "=== 演示完成 ==="
echo
echo "总结："
echo "- 使用 'uv run <工具名>' 来调用开发工具"
echo "- Black: 代码格式化"
echo "- Ruff: 快速代码检查和修复"
echo "- MyPy: 静态类型检查"
echo "- 所有配置都在 pyproject.toml 中"
